// Problem: 
// Contest: 
// URL: 
// Memory Limit: 
// Time Limit: 
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
struct pos
{
	int x,y;
	pos(int xx,int yy)
	{
		x=xx,y=yy;
	}
};
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
signed main()
{
	int t=1;
//	cin>>t;
	while(t--)
	{
		int n,fans=0,eans=0;
		cin>>n;
		vector<vector<char>> v(n+1,vector<char>(n+1));
		queue<pos> q;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				cin>>v[i][j];
			}	
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(v[i][j]=='#')
				{
					fans++;
					q.push(pos(i,j));
					v[i][j]='1';
					while(!q.empty())
					{
						pos tmp=q.front();
						q.pop();
						int x=tmp.x,y=tmp.y;
						for(int k=0;k<4;k++)
						{
							int xx=x+dx[k],yy=y+dy[k];
							if(xx<1||xx>n||yy<1||yy>n||v[xx][yy]=='.'||v[xx][yy]=='1')continue;
							q.push(pos(xx,yy));
							v[xx][yy]='1';
						}
					}
				}
			}	
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(v[i][j]=='1')
				{
					for(int k=0;k<4;k++)
					{
						int xx=i+dx[k],yy=j+dy[k];
						if(v[xx][yy]=='.')
							v[i][j]='3';
					}
				}
				//cout<<v[i][j]<<" ";
			}	
			//cout<<endl;
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(v[i][j]=='1')
				{
					eans++;
					q.push(pos(i,j));
					v[i][j]='2';
					while(!q.empty())
					{
						pos tmp=q.front();
						q.pop();
						int x=tmp.x,y=tmp.y;
						for(int k=0;k<4;k++)
						{
							int xx=x+dx[k],yy=y+dy[k];
							if(xx<1||xx>n||yy<1||yy>n||v[xx][yy]=='.'||v[xx][yy]=='2')continue;
							q.push(pos(xx,yy));
							v[xx][yy]='2';
						}
					}
				}
				//cout<<v[i][j]<<" ";
			}
			//cout<<endl;
		}
		cout<<fans-eans;
	}
	return 0;
}
